74 HttpContext $httpContext,
79 $this->scopeConfiguration = $context->getScopeConfig();
83 $this->httpContext = $httpContext;
96 $orderLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue(
97 GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER,
98 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
100 $itemLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue(
101 GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS,
102 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
104 if ($orderLevelGiftMessageConfiguration) {
107 $configuration[
'giftMessage'][
'orderLevel'] = $orderMessages ===
null ? true : $orderMessages->getData();
111 $configuration[
'isItemLevelGiftOptionsEnabled'] = $itemLevelGiftMessageConfiguration;
112 $configuration[
'giftMessage'][
'itemLevel'] = $itemMessages ===
null ? true : $itemMessages;
114 $configuration[
'priceFormat'] = $this->localeFormat->getPriceFormat(
116 $this->checkoutSession->getQuote()->getQuoteCurrencyCode()
119 $configuration[
'isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
121 $store = $this->storeManager->getStore();
131 private function isCustomerLoggedIn()
133 return (
bool)$this->httpContext->getValue(CustomerContext::CONTEXT_AUTH);
143 return $this->checkoutSession->getQuote()->getStore()->getCode();
153 return $this->checkoutSession->getQuote()->getIsVirtual();
163 $cartId = $this->checkoutSession->getQuoteId();
164 return $this->cartRepository->get(
$cartId);
174 $itemLevelConfig = [];
175 $quote = $this->checkoutSession->getQuote();
177 $itemId =
$item->getId();
178 $itemLevelConfig[$itemId] = [];
179 $isMessageAvailable =
$item->getProduct()->getGiftMessageAvailable();
182 $itemLevelConfig[$itemId][
'is_available'] = (bool)$isMessageAvailable;
186 $itemLevelConfig[$itemId][
'message'] =
$message->getData();
189 return count($itemLevelConfig) === 0 ? null : $itemLevelConfig;
getOrderLevelGiftMessages()
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\GiftMessage\Api\CartRepositoryInterface $cartRepository, \Magento\GiftMessage\Api\ItemRepositoryInterface $itemRepository, \Magento\Checkout\Model\Session $checkoutSession, HttpContext $httpContext, \Magento\Store\Model\StoreManagerInterface $storeManager, LocaleFormat $localeFormat, FormKey $formKey)
getItemLevelGiftMessages()