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.
3
votes
This is not a good idea. You can see the products only on the review step, and changing the qty there may lead to other errors. For example the shipping method may not be available for the selected qty. Or the shipping charges will change. I recommend using one of the many one-step-checkout extensions that exist out there. I recommend this one: shop.ecomdev.org/checkitout-magento-checkout-extension.html. It has built in what you need. Believe me it's worth the money. It will cost you more to do it and do it safely.
– Marius
we can manage the shipping rate and other things by loading page and using the default mangeto functionality for upadte cart. I developed code for this but I am facing only issue that the cart is not rendering on the checkout page. you can update the quantity by using the cart form and override the cartcontroller.
– urfusion
1 Answers
2
votes
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. :)