Modify the below file in your module
app/code/Vendor/Module/View/frontend/layout/checkout_onepage_success.xml
<?xml version="1.0"?>
<body>
<referenceContainer name="content">
<block class="Vendor\Module\Block\Thankyou" name="order.details.success" template="Vendor_Module::order/success.phtml" after="-">
</block>
</referenceContainer>
<referenceBlock name="checkout.success" remove="true"/>
</body>
app/code/Vendor/Module/Block/Thankyou.php
<?php
namespace Vendor\Module\Block;
class Thankyou extends \Magento\Sales\Block\Order\Totals
{
protected $checkoutSession;
protected $customerSession;
protected $_orderFactory;
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Customer\Model\Session $customerSession,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Registry $registry,
array $data = []
) {
parent::__construct($context, $registry, $data);
$this->checkoutSession = $checkoutSession;
$this->customerSession = $customerSession;
$this->_orderFactory = $orderFactory;
}
public function getOrder()
{
return $this->_order = $this->_orderFactory->create()->loadByIncrementId(
$this->checkoutSession->getLastRealOrderId());
}
public function getCustomerId()
{
return $this->customerSession->getCustomer()->getId();
}
}
app/code/Vendor/Module/View/frontend/templates/order/success.phtml
<?php
$order = $block->getOrder();
$payment = $order->getPayment();
$order->getShippingMethod();
if ($order->getShippingMethod() && $payment->getMethod):
?>
<div class="checkout-success">
<?php if($order->getIncrementId()):?>
<?php if ($block->getCustomerId()) :?>
<p><?php echo __('Your order number is: '.$order->getIncrementId().')' ?>
</p>
<?php else :?>
<p><?php echo __('Your order # is: <span>%1</span>.',$order->getIncrementId()) ?></p>
<?php endif;?>
<p><?php echo __('We\'ll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?php endif;?>
</div>