4

I want to add custom success page by overriding it's phtml.

Can anyone guide me how can I do this?

1
  • If you can purchase the Checkout success page extension, it will allow you to Display full order summary, the recommended list of products, Customize the success page and descriptions for each block and section and many other features
    – Mohit Rane
    May 31 at 9:57
6

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

4
  • Magento_Catalog or Magento_Checkout ? Apr 8 '19 at 11:38
  • Magento_Checkout
    – Rk Rathod
    Apr 8 '19 at 11:38
  • 1
    Thanks Ronak Rathod, will try this one Apr 8 '19 at 11:38
  • most welcome...
    – Rk Rathod
    Apr 8 '19 at 11:39
4

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

2
  • Thanks for the answer. +1 Apr 8 '19 at 12:07
  • you are welcome. +1 for your appreciation :) Apr 8 '19 at 12:17
3

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.

1
  • 1
    Thanks for the answer. +1 Apr 8 '19 at 12:07
3

you need to copy

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

into

app/design/frotend/<your package name/<your theme name>/Magento_Checkout/templates/success.phtml

then do cache flush using below command

php bin/mageno c:f

Then check it

For Magento 2.4 refere below link https://magento.stackexchange.com/a/326297/81914

1
  • Thanks for the answer. +1 Apr 8 '19 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.