cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 - How to update Minicart product price when qty increased

Magento 2 - How to update Minicart product price when qty increased

I want to increase product price when to increase qty in Minicart, but here order total increased but price not updated.

Screenshot : https://i.stack.imgur.com/uMJ53.png


1 REPLY 1

Re: Magento 2 - How to update Minicart product price when qty increased

Hi,

Bản sao của How To Hire A Dedicated Magento Developer.png

You have to make an Ajax call and execute the following functionality:-

   // Product ID and Quantity
    $pid = $_REQUEST['productId'];
    $qnt = $_REQUEST['qty'];
    $cart = Mage::getSingleton('checkout/cart');
    $items = $cart->getItems(); 
    foreach ($items as $item) :
        if($pid  == $item->getId()) :
            echo $item->getQty();
            $item->setQty($qnt); 
            $cart->save();
        endif;
    endforeach;     

This is just an example, you need to manage the variables according to your need. Whenever button is press just make a ajax call and update cart and then you need to update it via Ajax in other place where you want. Above code provide you the way to save product quantity to cart.