{"id":19904,"date":"2025-08-04T10:32:28","date_gmt":"2025-08-04T05:02:28","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/?p=19904"},"modified":"2025-08-04T10:32:30","modified_gmt":"2025-08-04T05:02:30","slug":"add-custom-block-to-the-order-success-page-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-custom-block-to-the-order-success-page-in-magento-2\/","title":{"rendered":"How To Add a Custom Block to the Order Success Page in Magento 2?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">By default, Magento 2 displays a standard thank you message on the order success page.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, many store owners would like to add additional content to enhance the customer experience or deliver important post-purchase information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This can be achieved by adding a custom block to the order success page in Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Custom Block Examples<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some commonly used custom block used:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Custom Blocks&nbsp;<\/strong><\/td><td><strong>Examples&nbsp;<\/strong><\/td><\/tr><tr><td>Personalized thank you custom block&nbsp;<\/td><td>Thank you for your order. We appreciate your support of our business.<\/td><\/tr><tr><td>Promo code for their next purchase<\/td><td>Use code MITHANKYOU to get 10% off your next order.<\/td><\/tr><tr><td>Post-purchase or delivery instructions<\/td><td>Your purchase includes one year of support.<\/td><\/tr><tr><td>Customer feedback or reviews block&nbsp;<\/td><td>How would you rate your experience with Meetanshi?<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">These are just a few examples. A custom block on the success page opens up many possibilities for improving customer engagement and retention<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Implement a Custom Block in Your Magento 2 Store?&nbsp;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To add a custom block, follow the steps below:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create the layout XML file<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Start with creating a layout XML file:<br>app\/code\/Vendor\/Extension\/view\/frontend\/layout\/checkout_onepage_success.xml<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;body>\n  &lt;referenceContainer name=\"order.success.additional.info\">\n    &lt;block class=\"Magento\\Framework\\View\\Element\\Template\"\n           name=\"custom.order.success\"\n           template=\"Vendor_Extension::success.phtml\"\n           after=\"-\">\n    &lt;\/block>\n  &lt;\/referenceContainer>\n&lt;\/body>\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Create the Corresponding Template File<br><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Then, create a corresponding template file:<br>app\/code\/Vendor\/Extension\/view\/frontend\/templates\/success.phtml<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;p>Content of your custom block&lt;\/p><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can now add your desired HTML or dynamic PHP content in the success.phtml file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This approach offers a flexible and clean way to extend the order success page functionality in Magento 2 without affecting the core files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Refer to our <a href=\"https:\/\/meetanshi.com\/magento-2-success-page.html\">Magento 2 success Page extension<\/a> to easily customize the order success page through admin settings. Enhance customer experience, boost retention, and drive repeat sales with flexible design and promotional options.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, Magento 2 displays a standard thank you message on the order success page.&nbsp; However, many store owners would like to add additional content&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-19904","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/19904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=19904"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/19904\/revisions"}],"predecessor-version":[{"id":19938,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/19904\/revisions\/19938"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=19904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=19904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=19904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}