我想在magento的结帐页面上提供更新产品数量的功能。因此,如果用户想要更新产品数量,他可以在结帐页面上进行,而不是返回购物车页面。
答案 0 :(得分:1)
你可以通过编辑item.phtml (template/checkout/onepage/review/item.phtml)
和第47行
<td class="a-center"><?php echo $_item->getQty() ?></td>
<td class="a-center">
<input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" name="update_cart_action" id="cup_<?php echo $_item->getId() ?>" class="input-text qty" maxlength="12" />
</td>
<td> <button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('shopping-cart-table'); ?>" id="up_<?php echo $_item->getId() ?>" class="button btn-update"><span><span><?php echo $this->__('Update'); ?></span></span></button><td>
and put Jquery code at the end
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".btn-update").click(function(){
var id = "#c"+this.id;
var quan = jQuery(id).val();
var lastChar = id.substr(id.length - 1);
jQuery.ajax({
url: "<?php echo Mage::getBaseUrl(); ?>checkout/cart/updatePosts/",
data: "cart["+lastChar+"][qty]="+quan,
async: false,
success: function(html){
location.reload();
}
})
})
})
</script>
现在覆盖cartcontroller.php
并放置原始cartcontroller.php
的所有功能,并按功能updatePostAction
重命名功能updatePostsAction
。
并将重定向路径更改为$this->_redirect('checkout/onepage');
就是这样。 :)