2

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 without reloading checkout page. I want to Provide this functionality without reloading page.

My Try:

I edit item.phtml (template/checkout/onepage/review/item.phtml) after 47th line number

<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>

This is My Jquery code which i put at the end of item

<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>

Than I 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');

But this is not working the error comes in console which i unable to solved and there are some problem inshort.

  • Can you provide the code you have tried so far? – Jaimin Sutariya Apr 24 '17 at 9:39
  • 1
    I update my Question. @JaiminSutariya – Jaimin Apr 24 '17 at 9:46
  • any suggestions or answer if you know @JaiminSutariya – Jaimin Apr 27 '17 at 10:30
  • The only thing I would suggest is not to put any cart update functionality on checkout page. It may distract users. Magento 2 has adopted to this and have removed menu section too so that users only concentrates on checkout process. If you really want to do this then you need to get response of order summary and replace it with your current order summery section. – Jaimin Sutariya Apr 27 '17 at 10:47
  • okay thanks will try and if you have code related to this then it will help me alot because this is client requirement which i want to complete. @JaiminSutariya – Jaimin Apr 27 '17 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.