I created a new module to display order total and some other information on Magento 2 success since page OOB success displays order id
alone. Steps taken are below.
Created new Block that extends Onepage Success and added new method(s).
Copied OOB Onepage success.phtml
to custom module view\frontend\templates\mysuccess.phtml
and modified to call new methods from custom Block.
Added di.xml to replace OOB <preference for="Magento\Checkout\Block\Onepage\Success" type="VendorName\Checkout\Block\Onepage\CustomSuccess"/>
Also created view\frontend\layout\checkout_onepage_success.xml
with below entry to use new template phtml file.
<referenceBlock name="checkout.success" template="VendorName_Checkout::mysuccess.phtml"/>
Also created module.xml and increased sequence number. Can anyone tell me what else do I need to use the new template and Block since I see blank success page instead of new block methods getting called?
I looked at Call custom phtml on success page without override and made similar changes but still no luck. What am I missing?
It's Magento 2.2.x CE.
Best Answer
You can insert your own
custom block
by overridingcheckout_onepage_success.xml
Try the below steps:
Don't forget to run the upgrade command and redeploy static view files.