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.

Метаданные статьи

Идентификатор статьи:
110
Категория:
Дата добавления:
09.10.2023 19:06:15
Просмотры:
65
Рейтинг (Голоса):
(0)