![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Cnc/Checkout/ViewModel/ |
<?php /** * Copyright (c) 2019 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * cnc_checkout_m2 * <[email protected]> */ namespace Cnc\Checkout\ViewModel; use Cnc\Catalog\Model\Attribute\MsiAttributes; use Cnc\Catalog\Model\Config; use Cnc\Catalog\Helper\Data as CatalogData; use Cnc\Checkout\Helper\Data; use Magento\Catalog\Model\ResourceModel\Product as ProductResource; use Magento\Checkout\Model\Session; use Magento\Framework\UrlInterface; use Magento\Framework\View\Element\Block\ArgumentInterface; use Magento\Sales\Model\Order\Payment; use Magento\Store\Model\StoreManagerInterface; class Success implements ArgumentInterface { /** * @var Session */ protected $checkoutSession; /** * @var Data */ private $helper; /** * @var UrlInterface */ private $urlbuilder; /** * @var StoreManagerInterface */ private $storeManager; /** * @var ProductResource */ private $productResource; /** * @var CatalogData */ private $catalogHerlper; /** * @var MsiAttributes */ private $msiAttributes; /** * Success constructor. * @param Session $checkoutSession * @param Data $helper * @param CatalogData $catalogHerlper * @param UrlInterface $urlbuilder * @param StoreManagerInterface $storeManager * @param ProductResource $productResource * @param MsiAttributes $msiAttributes */ public function __construct( Session $checkoutSession, Data $helper, CatalogData $catalogHerlper, UrlInterface $urlbuilder, StoreManagerInterface $storeManager, ProductResource $productResource, MsiAttributes $msiAttributes ) { $this->checkoutSession = $checkoutSession; $this->helper = $helper; $this->urlbuilder = $urlbuilder; $this->storeManager = $storeManager; $this->productResource = $productResource; $this->catalogHerlper = $catalogHerlper; $this->msiAttributes = $msiAttributes; } /** * Check if bank transfered was used and we can show proforma * * @param null $orderId * @return bool|int|null * @throws \Magento\Framework\Exception\InputException * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function canShowProforma($orderId = null) { if ($orderId == null) { $orderId = $this->checkoutSession->getLastRealOrder()->getId(); } return $this->helper->canShowProforma($orderId); } /** * Get url to customer account. * * @return string */ public function getCustomerAccountUrl() { return $this->urlbuilder->getUrl('customer/account'); } /** * Can show confirmation of shiping time on request. * * @return bool */ public function canShowConfirmationOfShippingTimeOnRequest() { $items = $this->checkoutSession->getLastRealOrder()->getAllItems(); foreach ($items as $item) { $buyRequest = $item->getBuyRequest(); $source = $buyRequest->getData('source'); $productSku = $item->getSku(); $attributeId = $this->msiAttributes->getAttributeId('cnc_availability'); if ($attributeId) { $attributeValue = $this->msiAttributes->getAttributeValue( $attributeId, $productSku, $source ); $value = $this->msiAttributes->getDropdownValue($attributeValue->getValue()); if ($value->getValue() == Config::PRODUCT_AVAILABILITY_ICON_CONFIRMATION_OF_SHIPPING_TIME_ON_REQUEST_VALUE) { return true; } } } return false; } /** * Get message of confirmation of shipping time on request. * * @return mixed */ public function getConfirmationOfShippingTimeOnRequestMessage() { return $this->helper->getConfirmationOfShippingTimeOnRequestMessage(); } }