How to update cart quantity of product using php in magento 2?
How to update cart quantity of product using php in magento 2?
just use these lines:
You can use the Quote repository \Magento\Quote\Api\CartRepositoryInterface
$quote = $this->quoteRepository->getActive($QuoteId);
$quoteItem = $quote->getItemById($itemId);
if (!$quoteItem) {
continue;
}
$quoteItem->setQty((double) $qty);
$quoteItem->save();
$this->quoteRepository->save($quote);
At this case, you also need quote id also
DELETE a quote item from Quote
use Magento\Quote\Model\Quote\Item\Repository
and use deleteById($QuoteId, $itemId),method.