How can I add custom success page

Copy This File :-

vendor/magento/module-checkout/view/frontend/templates/success.phtml

And Paste In Your Theme :-

app/design/frontend/your/theme/Magento_Checkout/view/frontend/templates/

After This You Can Change Success Page As Per Your Requirement


Go to magento core file given path and Copy This File

vendor/magento/module-checkout/view/frontend/templates/success.phtml

And Paste In below path

app/design/frontend/theme_package/theme_name/Magento_Checkout/view/frontend/templates/

Run below command

php bin/magento c:c

php bin/magento c:f


You can also do it in module way

app/code/Namespace/Modulename/view/frontend/layout/checkout_onepage_success.xml

<?xml version="1.0"?>
<body>
<referenceContainer name="order.success.additional.info">
    <block class="Namespace\Modulename\Block\Success"
           name="test.order.success"
           template="Namespace_Modulename::order/success.phtml"
           after="-">
    </block>
</referenceContainer>
</body>

app/code/Namespace/Modulename/view/frontend/templates/order/success.phtml

<?php echo __('Custom template file content.'); ?>
<?php echo $block->getSomething(); ?>

I hope it helps


You can do it by overriding or extending checkout_onepage_success.xml with your custom module. Follow these steps:

  1. Create your Success.php Block file in vendor\module\Block\OnePage
<?php
namespace vendor\module\Block\OnePage;
class Success extends \Magento\Framework\View\Element\Template
{
    public function getCustomSuccess()
    {
        return 'Your custom contents.';
    }
} 
  1. Create checkout_onepage_success.xml layout file in vendor\module\view\frontend\layout
<?xml version="1.0"?>
<body>
    <referenceContainer name="order.success.additional.info">
        <block class="vendor\module\Block\OnePage\Success"
               name="custom.order.success"
               template="Vendor_Module::order/success.phtml"
               after="-">
        </block>
    </referenceContainer>
</body>  
  1. Lastly, create phtml template file in vendor\module\view\frontend\templates\order\success.phtml
<?php /* @var $block \vendor\module\Block\OnePage\Success */?>
<?php echo __('This is a custom content.'); ?>
<?php echo $block->getCustomSuccess(); ?>  

After done with the above steps, run the upgrade command and redeploy static view files.