🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Add Custom Block in Checkout Success Page in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 2 min read

The importance of optimizing the “Thank You” page in E-commerce can’t be stressed enough. It is the best option to nurture the leads and get the most out of the customers who have once trusted you with their money!

Neil Patel shares how to increase ROI on the thank you page. However, for Magento 2 store owners, it is not going to be easy with the default success page after checkout. If you are using Magento 2 store and want top allow businesses to create a personalized post-purchase experience, enhancing customer satisfaction and brand loyalty than customize Thank You page in Magento 2.

Hence, I have come up with a solution that can be useful to optimize the thank you page in Magento 2 store. The below programmatic method is to add custom block in checkout success page in Magento 2.

The method can be used to add social media buttons, newsletter subscription buttons, coupon code blocks, more product suggestions, etc.

Get as much creative as you can and optimize the Magento 2 checkout success page to boost the conversion, improve the customer experience, and benefit the business!

Method to Add Custom Block in Checkout Success Page in Magento 2:

1. Create registration.php file in app\code\[Vendor]\[Namespace]\

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    '[Vendor]_[Namespace]',
    __DIR__
);

2. Create module.xml file in app\code\[Vendor]\[Namespace]\etc

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="[Vendor]_[Namespace]" setup_version="1.0.0"/>
</config>

3. Create checkout_onepage_success.xml file in app\code\[Vendor]\[Namespace]\view\frontend\layout

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="order.success.additional.info">
            <block class="Magento\Checkout\Block\Onepage\Success" name="custom.order.success"
                template="[Vendor]_[Namespace]::order/success.phtml" after="-">
            </block>
        </referenceContainer>
    </body>
</page>

4. Create success.phtml in app\code\[Vendor]\[Namespace]\view\frontend\templates\order\

<?php
echo "Here Additional Information"; //Bussiness logic

That’s it.

Feel free to share the above solution with fellow developers on social media.

Thanks!

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.