How can I update the quote item custom gift message? I’m thinking of adding that function inside the Module_Checkout/Model/Cart.php
inside the function updateItems
. So if I take a look at this file the content is
public function updateItems($data)
{
$infoDataObject = new MagentoFrameworkDataObject($data);
$this->_eventManager->dispatch(
'checkout_cart_update_items_before',
['cart' => $this, 'info' => $infoDataObject]
);
$qtyRecalculatedFlag = false;
foreach ($data as $itemId => $itemInfo) {
$item = $this->getQuote()->getItemById($itemId);
if (!$item) {
continue;
}
if (!empty($itemInfo['remove']) || isset($itemInfo['qty']) && $itemInfo['qty'] == '0') {
$this->removeItem($itemId);
continue;
}
$qty = isset($itemInfo['qty']) ? (double)$itemInfo['qty'] : false;
if ($qty > 0) {
$item->setQty($qty);
if ($item->getHasError()) {
throw new MagentoFrameworkExceptionLocalizedException(__($item->getMessage()));
}
if (isset($itemInfo['before_suggest_qty']) && $itemInfo['before_suggest_qty'] != $qty) {
$qtyRecalculatedFlag = true;
$this->messageManager->addNoticeMessage(
__('Quantity was recalculated from %1 to %2', $itemInfo['before_suggest_qty'], $qty),
'quote_item' . $item->getId()
);
}
}
}
if ($qtyRecalculatedFlag) {
$this->messageManager->addNoticeMessage(
__('We adjusted product quantities to fit the required increments.')
);
}
$this->_eventManager->dispatch(
'checkout_cart_update_items_after',
['cart' => $this, 'info' => $infoDataObject]
);
return $this;
}
So I want to add my function just after the condition of if ($qty > 0) {
how can I save the quote item gift message?