How to update product qty in cart?

It's doesn't work, but I need it done with this code, is it possible?

public function setProdQty($customerId,$upQty,$sendId){

    $quote = $this->quoteFactory->create()->loadByCustomer($customerId);

    return $quote->save();



try this:

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); 
    echo $cartId=$cart->getQuote()->getId();

    $itemId = 720;
    $itemQty = 1;

    $quote = $this->quoteRepository->getActive($cartId);
    $cartitems = $cart->getQuote()->getAllItems();

    $quoteItems[] = $cartitems;
Tags: Magento 2.x

Similar questions

Product Qty instead Salable Qty
How can i call Product Qty instead Salable Qty in i have deactivate Salable Qty in the trying to decrease product qty when the order is placed and not when it is shipped
Update Product Qty while product is being added to cart
I want to update qty to 2 when product is added to Cart. Basically I want that when a user ads a product to cart(qty is not visible for user), it is set to qty by default. I have created an observer and using event checkout_cart_product_add_after But when I try to add product to cart, somehow the CPU Usage % goes like 90% and server crashes and I h...
How do I set enable qty increments and set the qty increment in php
I have a large list of products that for each I have to enable qty_increments and set the qty_ increment to a specific value for that product. I am not sure how to do that in php. I know how to get and save the product just not how do enable and set the increments my input is: sku qty_increment sku qty_increment .... Thanks
Stock qty is not updating after order place with custom qty
I am trying to set stock qty of products with my custom stock qty after placing order. So I used following code in my config.xml file- Obeserver.php file - now if product with id 12345 has current stock qty 4 and an order with qty 1 of this product is placed then I want its qty should be 5 or whatever I want. but currently it is decreasing and show...
Magento 2.3 Saleable stock qty does not equal Global Attribute Qty
I have a simple product,(one of many), that is linked to a configurable product. I'm trying to get the salable quantity and attribute quantity to match. The site is in a dev env, so I don't think any items would be in cart. But the database is from a live copy a few hours ago. Toggling stock status, manage stock, changing data, re-indexing doesn't ...
Magento grid view qty box to show minimum qty
I want a QTY box next to the add to cart button in grid category view with the products minimum quantity. I have tried using the code below and it works except that the field always shows a '0'. How can I make it so that the field shows the minimum quantity of the product and not just '0'. This is what I used to modify the list.phtml file:

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.