We are trying to add custom option or custom value in quote item so that we can also get it in order item.
We are able to add custom value in quote using following code but it is get returning value in order item
$quote = $this->quoteRepository->getActive($cartId);
foreach ($quote->getAllItems() as $item) {
$item->setCustomValue(1);
$item->save();
}
Best Answer
You can achieve by a plugin in Magento 2.2.*
First of all, we need to create an observer file and one Magento event file to implement this functionality.
Once you have created this file, now you need to Create another file and named as: CompanyName\ModuleName/Model/SetAdditionalOptions.php
Now, We need to create a plugin for the retrieve custom option from cart to order.
First We need to create di.xml.
Once you have created this file, now you need to Create another file and named as: CompanyName\ModuleName\Model\Plugin\Quote\ToOrderItem.php