In Magento 2 I want to call my custom phtml
file order success page, but without overriding block. Is there any way to achieve this ?
I don't want to edit Magento success.phtml
as I am creating module.
Any help will appreciated
Thanks.
magento-2.1magento2
In Magento 2 I want to call my custom phtml
file order success page, but without overriding block. Is there any way to achieve this ?
I don't want to edit Magento success.phtml
as I am creating module.
Any help will appreciated
Thanks.
Best Answer
You can use any of Magento's layout file in your module to insert your custom block. In your case you need to use
checkout_onepage_success.xml
layout file in your custom module which will be active when a customer is on order success page. In the layout file you need to specify where you want to add your custom template usingreferenceContainer
orreferenceBlock
.For you I've created a simple module and tested it which works fine.
registration.php
composer.json
etc/module.xml
Block/Success.php
view/frontend/layout/checkout_onepage_success.xml
Specify
before
orafter
tag to specify where you want to add your template before or afterorder.success.additional.info
container. Hereafter="-"
will add your your template toorder.success.additional.info
container after all other containers present in the same section.view/frontend/templates/order/success.phtml