26 use Magento\Quote\Model\QuoteIdMaskFactory;
    40     private $attributeOptionManager;
    45     private $checkoutHelper;
    50     private $checkoutSession;
    55     private $customerRepository;
    60     private $customerSession;
    65     private $customerUrlManager;
    75     private $quoteRepository;
    80     private $quoteItemRepository;
    85     private $shippingMethodManager;
    90     private $configurationPool;
   175     private $addressMetadata;
   210         CheckoutHelper $checkoutHelper,
   212         CustomerRepository $customerRepository,
   214         CustomerUrlManager $customerUrlManager,
   215         HttpContext $httpContext,
   217         QuoteItemRepository $quoteItemRepository,
   218         ShippingMethodManager $shippingMethodManager,
   239         $this->checkoutHelper = $checkoutHelper;
   240         $this->checkoutSession = $checkoutSession;
   242         $this->customerSession = $customerSession;
   243         $this->customerUrlManager = $customerUrlManager;
   244         $this->httpContext = $httpContext;
   247         $this->shippingMethodManager = $shippingMethodManager;
   248         $this->configurationPool = $configurationPool;
   266         $this->attributeOptionManager = $attributeOptionManager ??
   278         $quoteId = $this->checkoutSession->getQuote()->getId();
   279         $output[
'formKey'] = $this->formKey->getFormKey();
   280         $output[
'customerData'] = $this->getCustomerData();
   281         $output[
'quoteData'] = $this->getQuoteData();
   282         $output[
'quoteItemData'] = $this->getQuoteItemData();
   283         $output[
'isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
   284         $output[
'selectedShippingMethod'] = $this->getSelectedShippingMethod();
   285         $output[
'storeCode'] = $this->getStoreCode();
   286         $output[
'isGuestCheckoutAllowed'] = $this->isGuestCheckoutAllowed();
   287         $output[
'isCustomerLoginRequired'] = $this->isCustomerLoginRequired();
   292         $output[
'forgotPasswordUrl'] = $this->getForgotPasswordUrl();
   294         $output[
'priceFormat'] = $this->localeFormat->getPriceFormat(
   296             $this->checkoutSession->getQuote()->getQuoteCurrencyCode()
   298         $output[
'basePriceFormat'] = $this->localeFormat->getPriceFormat(
   300             $this->checkoutSession->getQuote()->getBaseCurrencyCode()
   302         $output[
'postCodes'] = $this->postCodesConfig->getPostCodes();
   304         $output[
'totalsData'] = $this->getTotalsData();
   306             'isEnabled' => $this->scopeConfig->isSetFlag(
   307                 'shipping/shipping_policy/enable_shipping_policy',
   310             'shippingPolicyContent' => nl2br(
   311                 $this->scopeConfig->getValue(
   312                     'shipping/shipping_policy/shipping_policy_content',
   317         $output[
'activeCarriers'] = $this->getActiveCarriers();
   318         $output[
'originCountryCode'] = $this->getOriginCountryCode();
   319         $output[
'paymentMethods'] = $this->getPaymentMethods();
   320         $output[
'autocomplete'] = $this->isAutocompleteEnabled();
   321         $output[
'displayBillingOnPaymentMethod'] = $this->checkoutHelper->isDisplayBillingOnPaymentMethodAvailable();
   331     private function isAutocompleteEnabled()
   333         return $this->scopeConfig->getValue(
   334             \
Magento\Customer\Model\Form::XML_PATH_ENABLE_AUTOCOMPLETE,
   344     private function getCustomerData()
   347         if ($this->isCustomerLoggedIn()) {
   348             $customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
   352                 if (
$address->getCustomAttributes()) {
   353                     $customerData[
'addresses'][$key][
'custom_attributes'] = $this->filterNotVisibleAttributes(
   368     private function filterNotVisibleAttributes(array 
$attributes)
   370         $attributesMetadata = $this->addressMetadata->getAllAttributesMetadata();
   371         foreach ($attributesMetadata as $attributeMetadata) {
   372             if (!$attributeMetadata->isVisible()) {
   373                 unset(
$attributes[$attributeMetadata->getAttributeCode()]);
   386     private function getCustomerAddressInline(
$address)
   388         $builtOutputAddressData = $this->addressMapper->toFlatArray(
$address);
   389         return $this->addressConfig
   390             ->getFormatByCode(\
Magento\Customer\Model\Address\Config::DEFAULT_ADDRESS_FORMAT)
   392             ->renderArray($builtOutputAddressData);
   400     private function getQuoteData()
   403         if ($this->checkoutSession->getQuote()->getId()) {
   404             $quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
   405             $quoteData = 
$quote->toArray();
   406             $quoteData[
'is_virtual'] = 
$quote->getIsVirtual();
   408             if (!
$quote->getCustomer()->getId()) {
   412                     $this->checkoutSession->getQuote()->getId(),
   425     private function getQuoteItemData()
   428         $quoteId = $this->checkoutSession->getQuote()->getId();
   430             $quoteItems = $this->quoteItemRepository->getList(
$quoteId);
   434                 $quoteItemData[
$index][
'thumbnail'] = $this->imageHelper->init(
   436                     'product_thumbnail_image'   440         return $quoteItemData;
   452         $options = $this->configurationPool->getByProductType(
$item->getProductType())->getOptions(
$item);
   455             $helper = $this->configurationPool->getByProductType(
'default');
   458                 'cut_replacer' => 
' <a href="#" class="dots tooltip toggle" onclick="return false">...</a>'   475         return $this->customerUrlManager->getRegisterUrl();
   486         return $this->urlBuilder->getUrl(
'checkout');
   497         return $this->urlBuilder->getUrl(
'checkout/noroute');
   508         return $this->urlBuilder->getUrl(
'checkout/onepage/success/');
   516     private function getSelectedShippingMethod()
   518         $shippingMethodData = 
null;
   520             $quoteId = $this->checkoutSession->getQuote()->getId();
   525         } 
catch (\Exception $exception) {
   526             $shippingMethodData = 
null;
   528         return $shippingMethodData;
   537     private function getStoreCode()
   539         return $this->checkoutSession->getQuote()->getStore()->getCode();
   548     private function isGuestCheckoutAllowed()
   550         return $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote());
   559     private function isCustomerLoggedIn()
   561         return (
bool)$this->httpContext->getValue(CustomerContext::CONTEXT_AUTH);
   570     private function isCustomerLoginRequired()
   572         return $this->checkoutHelper->isCustomerMustBeLogged();
   581     private function getForgotPasswordUrl()
   583         return $this->customerUrlManager->getForgotPasswordUrl();
   602     private function getTotalsData()
   605         $totals = $this->cartTotalRepository->get($this->checkoutSession->getQuote()->getId());
   611         $totalSegmentsData = [];
   613         foreach (
$totals->getTotalSegments() as $totalSegment) {
   614             $totalSegmentArray = $totalSegment->toArray();
   615             if (is_object($totalSegment->getExtensionAttributes())) {
   616                 $totalSegmentArray[
'extension_attributes'] = $totalSegment->getExtensionAttributes()->__toArray();
   618             $totalSegmentsData[] = $totalSegmentArray;
   621         $totals->setTotalSegments($totalSegmentsData);
   622         $totalsArray = 
$totals->toArray();
   623         if (is_object(
$totals->getExtensionAttributes())) {
   624             $totalsArray[
'extension_attributes'] = 
$totals->getExtensionAttributes()->__toArray();
   634     private function getActiveCarriers()
   636         $activeCarriers = [];
   637         foreach ($this->shippingMethodConfig->getActiveCarriers() as $carrier) {
   638             $activeCarriers[] = $carrier->getCarrierCode();
   640         return $activeCarriers;
   648     private function getOriginCountryCode()
   650         return $this->scopeConfig->getValue(
   651             \
Magento\Shipping\Model\Config::XML_PATH_ORIGIN_COUNTRY_ID,
   653             $this->storeManager->getStore()
   663     private function getPaymentMethods()
   666         $quote = $this->checkoutSession->getQuote();
   667         if (
$quote->getIsVirtual()) {
   668             foreach ($this->paymentMethodManagement->getList(
$quote->getId()) as $paymentMethod) {
   670                     'code' => $paymentMethod->getCode(),
   671                     'title' => $paymentMethod->getTitle()
   686     private function setLabelsToAttributes(array $customAttributes) : array
   688         if (!empty($customAttributes)) {
   689             foreach ($customAttributes as $customAttributeCode => $customAttribute) {
   690                 $attributeOptionLabels = $this->getAttributeLabels($customAttribute, $customAttributeCode);
   691                 if (!empty($attributeOptionLabels)) {
   692                     $customAttributes[$customAttributeCode][
'label'] = implode(
', ', $attributeOptionLabels);
   697         return $customAttributes;
   709     private function getAttributeLabels(array $customAttribute, 
string $customAttributeCode) : array
   711         $attributeOptionLabels = [];
   713         if (!empty($customAttribute[
'value'])) {
   714             $customAttributeValues = explode(
',', $customAttribute[
'value']);
   715             $attributeOptions = $this->attributeOptionManager->getItems(
   716                 \
Magento\Customer\Model\Indexer\Address\AttributeProvider::ENTITY,
   720             if (!empty($attributeOptions)) {
   721                 foreach ($attributeOptions as $attributeOption) {
   722                     $attributeOptionValue = $attributeOption->getValue();
   723                     if (in_array($attributeOptionValue, $customAttributeValues)) {
   724                         $attributeOptionLabels[] = $attributeOption->getLabel() ?? $attributeOptionValue;
   730         return $attributeOptionLabels;
 
__construct(CheckoutHelper $checkoutHelper, CheckoutSession $checkoutSession, CustomerRepository $customerRepository, CustomerSession $customerSession, CustomerUrlManager $customerUrlManager, HttpContext $httpContext, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, QuoteItemRepository $quoteItemRepository, ShippingMethodManager $shippingMethodManager, ConfigurationPool $configurationPool, QuoteIdMaskFactory $quoteIdMaskFactory, LocaleFormat $localeFormat, \Magento\Customer\Model\Address\Mapper $addressMapper, \Magento\Customer\Model\Address\Config $addressConfig, FormKey $formKey, \Magento\Catalog\Helper\Image $imageHelper, \Magento\Framework\View\ConfigInterface $viewConfig, \Magento\Directory\Model\Country\Postcode\ConfigInterface $postCodesConfig, Cart\ImageProvider $imageProvider, \Magento\Directory\Helper\Data $directoryHelper, CartTotalRepositoryInterface $cartTotalRepository, ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\Config $shippingMethodConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement, UrlInterface $urlBuilder, AddressMetadataInterface $addressMetadata=null, AttributeOptionManagementInterface $attributeOptionManager=null)
getDefaultSuccessPageUrl()
getFormattedOptionValue($item)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]