79 public function get(
$cartId, $itemId)
89 __(
'No item with the provided ID was found in the Cart. Verify the ID and try again.')
92 $messageId =
$item->getGiftMessageId();
102 return $this->messageFactory->create()->load($messageId);
118 throw new NoSuchEntityException(
120 'No product with the "%1" itemId exists in the Cart. Verify your information and try again.',
126 if (
$item->getIsVirtual()) {
127 throw new InvalidTransitionException(
__(
'Gift messages can\'t be used for virtual products.'));
130 if ($messageText && !$this->helper->isMessagesAllowed(
'items',
$quote, $this->storeManager->getStore())) {
131 throw new CouldNotSaveException(
__(
"The gift message isn't available."));
__construct(\Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager, \Magento\GiftMessage\Helper\Message $helper, \Magento\GiftMessage\Model\MessageFactory $messageFactory)
save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage, $itemId)