/** * @return bool */ public function isValid() { if (!$this->checkoutSession->getLastSuccessQuoteId()) { return false; } if (!$this->checkoutSession->getLastQuoteId() || !$this->checkoutSession->getLastOrderId()) { return false; } return true; }
public function getPostData() { $orderId = $this->_checkoutSession->getLastOrderId(); if ($orderId) { $incrementId = $this->_checkoutSession->getLastRealOrderId(); return $this->Config->getPostData($incrementId); } }
/** * @return \Magento\Sales\Model\Order */ public function getOrder() { if ($this->_order == null) { $this->_order = $this->_orderFactory->create()->load($this->_checkoutSession->getLastOrderId()); } return $this->_order; }
/** * Execute request * * @throws AlreadyExistsException * @throws NoSuchEntityException * @throws \Exception * @return void */ public function executeInternal() { if ($this->customerSession->isLoggedIn()) { $this->messageManager->addError(__("Customer is already registered")); return; } $orderId = $this->checkoutSession->getLastOrderId(); if (!$orderId) { $this->messageManager->addError(__("Your session has expired")); return; } try { $this->orderCustomerService->create($orderId); } catch (\Exception $e) { $this->messageManager->addException($e, $e->getMessage()); throw $e; } }
/** * Execute request * * @throws AlreadyExistsException * @throws NoSuchEntityException * @throws \Exception * @return \Magento\Framework\Controller\Result\Json */ public function execute() { /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->_objectManager->get(\Magento\Framework\Controller\Result\JsonFactory::class)->create(); if ($this->customerSession->isLoggedIn()) { return $resultJson->setData(['errors' => true, 'message' => __('Customer is already registered')]); } $orderId = $this->checkoutSession->getLastOrderId(); if (!$orderId) { return $resultJson->setData(['errors' => true, 'message' => __('Your session has expired')]); } try { $this->orderCustomerService->create($orderId); return $resultJson->setData(['errors' => false, 'message' => __('A letter with further instructions will be sent to your email.')]); } catch (\Exception $e) { $this->messageManager->addException($e, $e->getMessage()); throw $e; } }
/** * Is valid session? * * @param \Magento\Checkout\Model\Session $checkoutSession * @return bool */ public function isValid(\Magento\Checkout\Model\Session $checkoutSession) { if (!$checkoutSession->getLastSuccessQuoteId()) { return false; } if (!$checkoutSession->getLastQuoteId() || !$checkoutSession->getLastOrderId()) { return false; } return true; }
/** * Is valid session? * * @param \Magento\Checkout\Model\Session $checkoutSession * @return bool */ public function isValid(\Magento\Checkout\Model\Session $checkoutSession) { if (!$checkoutSession->getLastSuccessQuoteId()) { return false; } if (!$checkoutSession->getLastQuoteId() || !$checkoutSession->getLastOrderId() && count($checkoutSession->getLastRecurringPaymentIds()) == 0) { return false; } return true; }
/** * @return int|false */ public function getOrderIdForPaymentStart() { if ($this->checkoutSuccessValidator->isValid()) { return $this->checkoutSession->getLastOrderId(); } $orderId = $this->request->getParam('id'); if ($orderId) { return $orderId; } return false; }
/** * Get last order ID from session, fetch it and check whether it can be viewed, printed etc * * @return void */ protected function _prepareLastOrder() { $orderId = $this->_checkoutSession->getLastOrderId(); if ($orderId) { $order = $this->_orderFactory->create()->load($orderId); if ($order->getId()) { $isVisible = !in_array($order->getStatus(), $this->_orderConfig->getInvisibleOnFrontStatuses()); $canView = $this->httpContext->getValue(Context::CONTEXT_AUTH) && $isVisible; $this->addData(['is_order_visible' => $isVisible, 'view_order_url' => $this->getUrl('sales/order/view/', ['order_id' => $orderId]), 'print_url' => $this->getUrl('sales/order/print', ['order_id' => $orderId]), 'can_print_order' => $isVisible, 'can_view_order' => $canView, 'order_id' => $order->getIncrementId()]); } } }
/** * Validate order addresses * * @return bool */ protected function validateAddresses() { $order = $this->orderRepository->get($this->checkoutSession->getLastOrderId()); $addresses = $order->getAddresses(); foreach ($addresses as $address) { $result = $this->addressValidator->validateForCustomer($address); if (is_array($result) && !empty($result)) { return false; } } return true; }