{"id":569,"date":"2019-08-27T06:26:09","date_gmt":"2019-08-27T06:26:09","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/08\/27\/add-custom-block-in-checkout-success-page-in-magento-2\/"},"modified":"2025-05-22T16:06:27","modified_gmt":"2025-05-22T10:36:27","slug":"add-custom-block-in-checkout-success-page-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-custom-block-in-checkout-success-page-in-magento-2\/","title":{"rendered":"How to Add Custom Block in Checkout Success Page in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The importance of optimizing the \u201cThank You\u201d page in E-commerce can\u2019t 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!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/neilpatel.com\/blog\/post-sale-now-what\/\" target=\"_blank\" rel=\"noreferrer noopener\">Neil Patel<\/a> shares how to increase ROI on the <a href=\"https:\/\/www.drip.com\/blog\/e-commerce-thank-you-email-examples\" target=\"_blank\" rel=\"noreferrer noopener\">thank you page<\/a>. 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 <a href=\"https:\/\/meetanshi.com\/blog\/customize-thank-you-page-in-magento-2\/\">customize Thank You page in Magento 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 <em><strong>add custom block in checkout success page in Magento 2<\/strong><\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The method can be used to add social media buttons, newsletter subscription buttons, coupon code blocks, more product suggestions, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Add Custom Block in Checkout Success Page in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create <em><strong>registration.php<\/strong><\/em> file in <strong><strong><strong><strong>app\\code\\[Vendor]\\[Namespace]\\<\/strong><\/strong><\/strong><\/strong><\/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;?php\n\\Magento\\Framework\\Component\\ComponentRegistrar::register(\n    \\Magento\\Framework\\Component\\ComponentRegistrar::MODULE,\n    '[Vendor]_[Namespace]',\n    __DIR__\n);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create <em><strong>module.xml<\/strong><\/em> file in <strong><strong><strong><strong>app\\code\\[Vendor]\\[Namespace]\\etc<\/strong><\/strong><\/strong><\/strong><\/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;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Module\/etc\/module.xsd\">\n    &lt;module name=\"[Vendor]_[Namespace]\" setup_version=\"1.0.0\"\/>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Create <em><strong>checkout_onepage_success.xml<\/strong><\/em>&nbsp;file in&nbsp;<strong><strong>app\\code\\[Vendor]\\[Namespace]\\view\\frontend\\layout<\/strong><\/strong><\/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;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"1column\"\n      xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\">\n    &lt;body>\n        &lt;referenceContainer name=\"order.success.additional.info\">\n            &lt;block class=\"Magento\\Checkout\\Block\\Onepage\\Success\" name=\"custom.order.success\"\n                template=\"[Vendor]_[Namespace]::order\/success.phtml\" after=\"-\">\n            &lt;\/block>\n        &lt;\/referenceContainer>\n    &lt;\/body>\n&lt;\/page><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. Create <em><strong>success.phtml<\/strong><\/em> in <strong><strong><strong><strong>app\\code\\[Vendor]\\[Namespace]\\view\\frontend\\templates\\order\\<\/strong><\/strong><\/strong><\/strong><\/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;?php\necho \"Here Additional Information\"; \/\/Bussiness logic<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the above solution with fellow developers on social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The importance of optimizing the \u201cThank You\u201d page in E-commerce can\u2019t 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 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-569","post","type-post","status-publish","format-standard","hentry","category-magento"],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/569","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=569"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/569\/revisions"}],"predecessor-version":[{"id":15293,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/569\/revisions\/15293"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}