/
Success.php
31 lines (30 loc) · 956 Bytes
/
Success.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Controller\Onepage;
class Success extends \Magento\Checkout\Controller\Onepage
{
/**
* Order success action
*
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$session = $this->getOnepage()->getCheckout();
if (!$this->_objectManager->get('Magento\Checkout\Model\Session\SuccessValidator')->isValid()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
}
$session->clearQuote();
//@todo: Refactor it to match CQRS
$resultPage = $this->resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$session->getLastOrderId()]]
);
return $resultPage;
}
}