Reputation: 5501
I want to provide functionality to update product quantity on checkout page of magento. so if user want to update the product quantity he can do it on checkout page rather to go back on cart page.
Upvotes: 3
Views: 4196
Reputation: 5501
you can do it by editing item.phtml (template/checkout/onepage/review/item.phtml)
and these lines after line no #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>
now override cartcontroller.php
and place all the functions of the original cartcontroller.php
and rename function updatePostAction
by function updatePostsAction
.
and change the redirect path to $this->_redirect('checkout/onepage');
that's all. :)
Upvotes: 2