Yes, you could do that.
First, You have to build a module which frontName is order
.Check What is a frontName?
Second is that redirect to checkout/onepage/success/
to order/?ORDERID
Create URL:
First, As you want to start url with order
, So the routes.xml
code at app/code/{Vendorname}/{Modulename}/etc/frontend.Will be like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<!-- frontname is Order as you want to uRL is Frontend -->
<route id="order" frontName="order">
<module name="{Vendorname}_{Modulename}" />
</route>
</router>
</config>
and You have to create Action file Index.php
at app/code/{Vendorname}/{Modulename}/Controller/Index
And Code Should be like:
<?php
namespace {Vendorname}\{Modulename}\Controller\Index;
class Index 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::class)->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;
}
}
Redirect checkout/onepage/success/
to order/?ORDERID
On this case, you have to create a plugin over Magento\Checkout\Controller\Onepage\Success
, create around plugin on execute()