You need to change the URL from the sales template to add increment_id. After that, you can try the following changes, allowing you to load the order by increment_id instead of ID.
app/code/Vendor/Sales/etc/di.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Sales\Controller\AbstractController\OrderLoader">
<plugin name="order_load_by_increment_id" type="Vendor\Sales\Controller\AbstractController\OrderLoader" sortOrder="1"/>
</type>
</config>
And now:
app/code/Vendor/Sales/Controller/AbstractController/OrderLoader.php
<?php
namespace Vendor\Sales\Controller\AbstractController;
use Magento\Framework\App\RequestInterface;
use Magento\Sales\Controller\AbstractController\OrderLoader as BaseOrderLoader;
use Magento\Sales\Model\OrderFactory;
class OrderLoader
{
/**
* @param OrderFactory $orderFactory
*/
public function __construct(
private OrderFactory $orderFactory
) {
}
/**
* @param BaseOrderLoader $subject
* @param RequestInterface $request
*/
public function beforeLoad(
BaseOrderLoader $subject,
RequestInterface $request
) {
$orderId = $request->getParam('order_id');
if ($orderId) {
$order = $this->orderFactory->create();
$order = $order->loadByIncrementId($orderId);
if ($order && $order->getId()) {
$request->setParam('order_id', $order->getId());
}
}
}
}