Magento - How to add custom block to Checkout success page

Magento - How to add custom block to Checkout success page

July 18, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - How to add custom block to Checkout success page

[Blog Post: Add Custom Block to Magento Checkout Success Page]

Introduction

In this tutorial, we’ll guide you through adding a custom block to the Magento checkout success page without duplicating the template file. This approach allows for cleaner code and easier maintenance of your e-commerce store.

Understanding the Checkout Success Page Layout

The checkout success page in Magento is defined by the onepage.phtml template located at app/design/frontend/default/default/template/checkout/success.phtml. By default, this page displays a summary of the order placed by the customer.

To add custom content to this page, you can create a new block and reference it within the layout XML file. This method keeps your original templates clean and ensures that any updates to the core files won’t override your customizations.

Creating the Custom Block

  1. Create a new block file under app/code/local/YourVendor/YourModule/Block/Checkout/Details.php:
class YourVendor_YourModule_Block_Checkout_Details extends Mage_Checkout_Block_Onepage_Success
{
    // Add any necessary methods or properties here
}
  1. Create a corresponding template file for your custom block under app/design/frontend/default/default/template/yourmodule/checkout/details.phtml:
<?php
echo "Your custom content here";
?>
  1. In your layout XML file (e.g., app/design/frontend/default/default/layout/yourmodule.xml), add a reference to the new block within the checkout_onepage_success handle:
<checkout_onepage_success>
    <reference name="checkout.success">
        <block type="yourmodule/checkout_details" name="yourmodule.checkout.details" template="yourmodule/checkout/details.phtml"/>
    </reference>
</checkout_onepage_success>

Common Pitfalls and Solutions

  • Incorrect Block Type: Ensure that the block type in your XML file matches the class name of your custom block. In our example, yourmodule/checkout_details corresponds to YourVendor_YourModule_Block_Checkout_Details.

  • Missing Layout Update: Make sure you have an entry for yourmodule.xml under app/etc/modules/YourVendor_YourModule.xml:

<config>
    <modules>
        <YourVendor_YourModule>
            <active>true</active>
            ...
            <layout version="0.1.0">
                <file>yourmodule.xml</file>
            </layout>
        </YourVendor_YourModule>
    </modules>
</config>

Adding Custom Blocks to Other Pages

You can apply a similar approach to add custom blocks to other pages in Magento, such as the product view page.

To add a block to product.info.additional, your XML layout would look like this:

<catalog_product_view>
    <reference name="product.info.additional">
        <block type="yourmodule/product_view" name="yourmodule.product.details" template="yourmodule/product/details.phtml"/>
    </reference>
</catalog_product_view>

However, adding a block to product.info might not work as expected due to the default layout structure. To display your custom content alongside the product details, consider using an existing container like product.info.additional.

Conclusion

Adding a custom block to the Magento checkout success page is a clean and efficient way to extend the functionality of your store without modifying core templates directly.

By following this approach, you can maintain a clear separation between your customizations and the default Magento layout. This practice promotes easier updates, better code organization, and improved performance.

Remember to keep your layout XML files well-organized and follow Magento’s naming conventions for optimal compatibility with future updates. For more advanced customizations and best practices, consider exploring Magento 2 development resources or consulting a professional Magento developer at Laravel Company.

Happy coding!

Checkout Extensions Themes Orders

Our network