Extend Magento 2 Onepage Success Block and success.phtml to display addition order informationCall custom phtml on success page without overrideWhy is overriding a block function causing template errors?Magento 2 create custom block and phtml in Magento_Customer moduleReplicate order summary block Magento 2How to get the order id in success.phtml?Display Remove and Edit Item button in Order summary in Onepage Checkout page Magento2Magento 2.2.3 move block XMLsuccess page template file not called : M2How to call phtml file from html in Magento 2?Magento2: Shipping method with Pickup StoreHow to customize order succes page url and add some order details
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
Which country benefited the most from UN Security Council vetoes?
What does "Puller Prush Person" mean?
Has there ever been an airliner design involving reducing generator load by installing solar panels?
Is it legal for company to use my work email to pretend I still work there?
What's the point of deactivating Num Lock on login screens?
Is it possible to do 50 km distance without any previous training?
LWC SFDX source push error TypeError: LWC1009: decl.moveTo is not a function
What does the "remote control" for a QF-4 look like?
Why is Minecraft giving an OpenGL error?
Add text to same line using sed
Rock identification in KY
infared filters v nd
Why can't we play rap on piano?
How is it possible to have an ability score that is less than 3?
How much of data wrangling is a data scientist's job?
When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?
How can bays and straits be determined in a procedurally generated map?
What is a clear way to write a bar that has an extra beat?
Why can't I see bouncing of a switch on an oscilloscope?
Can a vampire attack twice with their claws using Multiattack?
Why is 150k or 200k jobs considered good when there's 300k+ births a month?
Roll the carpet
LaTeX: Why are digits allowed in environments, but forbidden in commands?
Extend Magento 2 Onepage Success Block and success.phtml to display addition order information
Call custom phtml on success page without overrideWhy is overriding a block function causing template errors?Magento 2 create custom block and phtml in Magento_Customer moduleReplicate order summary block Magento 2How to get the order id in success.phtml?Display Remove and Edit Item button in Order summary in Onepage Checkout page Magento2Magento 2.2.3 move block XMLsuccess page template file not called : M2How to call phtml file from html in Magento 2?Magento2: Shipping method with Pickup StoreHow to customize order succes page url and add some order details
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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 viewfrontendtemplatesmysuccess.phtml
and modified to call new methods from custom Block.
Added di.xml to replace OOB <preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorNameCheckoutBlockOnepageCustomSuccess"/>
Also created viewfrontendlayoutcheckout_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.
magento2
add a comment |
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 viewfrontendtemplatesmysuccess.phtml
and modified to call new methods from custom Block.
Added di.xml to replace OOB <preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorNameCheckoutBlockOnepageCustomSuccess"/>
Also created viewfrontendlayoutcheckout_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.
magento2
did you get any error?
– magefms
2 days ago
No errors, it wouldn't call any methods from the custom block and also doesn't display OOB order number and other information, all that section is blank on the success page with no errors.
– cnu
2 days ago
add a comment |
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 viewfrontendtemplatesmysuccess.phtml
and modified to call new methods from custom Block.
Added di.xml to replace OOB <preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorNameCheckoutBlockOnepageCustomSuccess"/>
Also created viewfrontendlayoutcheckout_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.
magento2
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 viewfrontendtemplatesmysuccess.phtml
and modified to call new methods from custom Block.
Added di.xml to replace OOB <preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorNameCheckoutBlockOnepageCustomSuccess"/>
Also created viewfrontendlayoutcheckout_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.
magento2
magento2
edited 2 days ago
Raj Mohan R
4109
4109
asked 2 days ago
cnucnu
786
786
did you get any error?
– magefms
2 days ago
No errors, it wouldn't call any methods from the custom block and also doesn't display OOB order number and other information, all that section is blank on the success page with no errors.
– cnu
2 days ago
add a comment |
did you get any error?
– magefms
2 days ago
No errors, it wouldn't call any methods from the custom block and also doesn't display OOB order number and other information, all that section is blank on the success page with no errors.
– cnu
2 days ago
did you get any error?
– magefms
2 days ago
did you get any error?
– magefms
2 days ago
No errors, it wouldn't call any methods from the custom block and also doesn't display OOB order number and other information, all that section is blank on the success page with no errors.
– cnu
2 days ago
No errors, it wouldn't call any methods from the custom block and also doesn't display OOB order number and other information, all that section is blank on the success page with no errors.
– cnu
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
You can insert your own custom block
by overriding checkout_onepage_success.xml
Try the below steps:
- Create your CustomSuccess.php Block file in vendormoduleBlockOnePage
<?php
namespace vendormoduleBlockOnePage;
class CustomSuccess extends MagentoFrameworkViewElementTemplate
public function getCustomSuccess()
return 'Your custom block contents.';
- Create checkout_onepage_success.xml layout file in vendormoduleviewfrontendlayout
<?xml version="1.0"?>
<body>
<referenceContainer name="order.success.additional.info">
<block class="vendormoduleBlockOnePageCustomSuccess"
name="custom.order.success"
template="Vendor_Module::order/success.phtml"
after="-">
</block>
</referenceContainer>
</body>
- Lastly, create phtml template file in vendormoduleviewfrontendtemplatesorder
<?php /* @var $block vendormoduleBlockOnePageCustomSuccess */?>
<?php echo __('This is a custom content.'); ?>
<?php echo $block->getCustomSuccess(); ?>
Don't forget to run the upgrade command and redeploy static view files.
I have made layout xml changes as above butt still not working. I may have mixed it up with changes from both answers, I am not sure if below custom module di.xml, and module.xml are necessary since the custom template should get data from the new Block and display after OOB success page. Am I right? di.xml:<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorCheckoutBlockOnepageCustomSuccess"/>
module.xml:<module name="Vendor_Checkout" setup_version="2.0.0"> <sequence> <module name="Magento_Checkout"/> </sequence> </module>
– cnu
2 days ago
I removed above mentioned entries from di.xml and module.xml and I still don't see custom phtml code being rendered though the module is enabled, ran upgrade and deployed static assets, cleared cache as well couple of times. Not sure what I am missing now.
– cnu
2 days ago
At the end it was blank config entry in di.xml since layout entry already is referencing new Block and template phtml file as below. Other layout entry may have also worked but now left it with following and it's working now.<referenceContainer name="order.success.additional.info"> <block class="VendoNameCheckoutBlockOnepageCustomSuccess" name="custom.order.success" template="VendoName_Checkout::checkout/mysuccess.phtml" after="-"> </block> </referenceContainer>
– cnu
2 days ago
My bad, there was a lower case letter in the vendor name inside checkout_onepage_success.xml while referencing the custom template, hence it wasn't called. I saw this issue in Developer mode but didn't enable it again since I thought I had fixed. It came up again since I was trying multiple things
– cnu
2 days ago
add a comment |
You can follow below file path to get additional order information to display order success page like order total.
File path: magento/app/code/Vendor/OrderSuccess/registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Vendor_OrderSuccess',
__DIR__
);
File path: magento/app/code/Vendor/OrderSuccess/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_OrderSuccess" setup_version="1.0.0">
<sequence>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
File path: magento/app/code/Vendor/OrderSuccess/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorOrderSuccessBlockOnepageCustomSuccess" />
</config>
File path:
magento/app/code/Vendor/OrderSuccess/Block/Onepage/CustomSuccess.php
<?php
namespace VendorOrderSuccessBlockOnepage;
class CustomSuccess extends MagentoCheckoutBlockOnepageSuccess
protected $orderItemsDetails;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderConfig $orderConfig,
MagentoFrameworkAppHttpContext $httpContext,
MagentoSalesModelOrder $orderItemsDetails,
array $data = []
)
parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data);
$this->orderItemsDetails = $orderItemsDetails;
public function getOrderItemsDetails()
$IncrementId = $this->_checkoutSession->getLastRealOrder()->getIncrementId();
$order = $this->orderItemsDetails->loadByIncrementId($IncrementId);
return $order;
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/layout/checkout_onepage_success.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="VendorOrderSuccessBlockOnepageCustomSuccess" name="checkout.successcustom" template="Vendor_OrderSuccess::mysuccess.phtml">
</block>
</referenceContainer>
</body>
</page>
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/templates/mysuccess.phtml
<?php $_order = $block->getOrderItemsDetails(); ?>
<?php echo "Sub Total"; ?><?php echo $_order->formatPrice($_order->getSubTotal()); ?>
<?php echo "Grand Total"; ?> <?php echo $_order->formatPrice($_order->getGrandTotal()); ?>
Let me know if any query.
Hope it help!
@cnu your commented xml code only work for default template.
– Kirti Nariya
2 days ago
Thanks Kirti. I see below entry in OOB checkout_onepage_success.xml, and I don't see anything printed or called from the customsuccess.phtml, is there anything else that needs to be done to use custom template code after OOB template data?
– cnu
2 days ago
<referenceContainer name="content"> <block class="MagentoCheckoutBlockOnepageSuccess" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"> <container name="order.success.additional.info" label="Order Success Additional Info"/> </block> <block class="MagentoCheckoutBlockRegistration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/> </referenceContainer>
– cnu
2 days ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268440%2fextend-magento-2-onepage-success-block-and-success-phtml-to-display-addition-ord%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can insert your own custom block
by overriding checkout_onepage_success.xml
Try the below steps:
- Create your CustomSuccess.php Block file in vendormoduleBlockOnePage
<?php
namespace vendormoduleBlockOnePage;
class CustomSuccess extends MagentoFrameworkViewElementTemplate
public function getCustomSuccess()
return 'Your custom block contents.';
- Create checkout_onepage_success.xml layout file in vendormoduleviewfrontendlayout
<?xml version="1.0"?>
<body>
<referenceContainer name="order.success.additional.info">
<block class="vendormoduleBlockOnePageCustomSuccess"
name="custom.order.success"
template="Vendor_Module::order/success.phtml"
after="-">
</block>
</referenceContainer>
</body>
- Lastly, create phtml template file in vendormoduleviewfrontendtemplatesorder
<?php /* @var $block vendormoduleBlockOnePageCustomSuccess */?>
<?php echo __('This is a custom content.'); ?>
<?php echo $block->getCustomSuccess(); ?>
Don't forget to run the upgrade command and redeploy static view files.
I have made layout xml changes as above butt still not working. I may have mixed it up with changes from both answers, I am not sure if below custom module di.xml, and module.xml are necessary since the custom template should get data from the new Block and display after OOB success page. Am I right? di.xml:<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorCheckoutBlockOnepageCustomSuccess"/>
module.xml:<module name="Vendor_Checkout" setup_version="2.0.0"> <sequence> <module name="Magento_Checkout"/> </sequence> </module>
– cnu
2 days ago
I removed above mentioned entries from di.xml and module.xml and I still don't see custom phtml code being rendered though the module is enabled, ran upgrade and deployed static assets, cleared cache as well couple of times. Not sure what I am missing now.
– cnu
2 days ago
At the end it was blank config entry in di.xml since layout entry already is referencing new Block and template phtml file as below. Other layout entry may have also worked but now left it with following and it's working now.<referenceContainer name="order.success.additional.info"> <block class="VendoNameCheckoutBlockOnepageCustomSuccess" name="custom.order.success" template="VendoName_Checkout::checkout/mysuccess.phtml" after="-"> </block> </referenceContainer>
– cnu
2 days ago
My bad, there was a lower case letter in the vendor name inside checkout_onepage_success.xml while referencing the custom template, hence it wasn't called. I saw this issue in Developer mode but didn't enable it again since I thought I had fixed. It came up again since I was trying multiple things
– cnu
2 days ago
add a comment |
You can insert your own custom block
by overriding checkout_onepage_success.xml
Try the below steps:
- Create your CustomSuccess.php Block file in vendormoduleBlockOnePage
<?php
namespace vendormoduleBlockOnePage;
class CustomSuccess extends MagentoFrameworkViewElementTemplate
public function getCustomSuccess()
return 'Your custom block contents.';
- Create checkout_onepage_success.xml layout file in vendormoduleviewfrontendlayout
<?xml version="1.0"?>
<body>
<referenceContainer name="order.success.additional.info">
<block class="vendormoduleBlockOnePageCustomSuccess"
name="custom.order.success"
template="Vendor_Module::order/success.phtml"
after="-">
</block>
</referenceContainer>
</body>
- Lastly, create phtml template file in vendormoduleviewfrontendtemplatesorder
<?php /* @var $block vendormoduleBlockOnePageCustomSuccess */?>
<?php echo __('This is a custom content.'); ?>
<?php echo $block->getCustomSuccess(); ?>
Don't forget to run the upgrade command and redeploy static view files.
I have made layout xml changes as above butt still not working. I may have mixed it up with changes from both answers, I am not sure if below custom module di.xml, and module.xml are necessary since the custom template should get data from the new Block and display after OOB success page. Am I right? di.xml:<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorCheckoutBlockOnepageCustomSuccess"/>
module.xml:<module name="Vendor_Checkout" setup_version="2.0.0"> <sequence> <module name="Magento_Checkout"/> </sequence> </module>
– cnu
2 days ago
I removed above mentioned entries from di.xml and module.xml and I still don't see custom phtml code being rendered though the module is enabled, ran upgrade and deployed static assets, cleared cache as well couple of times. Not sure what I am missing now.
– cnu
2 days ago
At the end it was blank config entry in di.xml since layout entry already is referencing new Block and template phtml file as below. Other layout entry may have also worked but now left it with following and it's working now.<referenceContainer name="order.success.additional.info"> <block class="VendoNameCheckoutBlockOnepageCustomSuccess" name="custom.order.success" template="VendoName_Checkout::checkout/mysuccess.phtml" after="-"> </block> </referenceContainer>
– cnu
2 days ago
My bad, there was a lower case letter in the vendor name inside checkout_onepage_success.xml while referencing the custom template, hence it wasn't called. I saw this issue in Developer mode but didn't enable it again since I thought I had fixed. It came up again since I was trying multiple things
– cnu
2 days ago
add a comment |
You can insert your own custom block
by overriding checkout_onepage_success.xml
Try the below steps:
- Create your CustomSuccess.php Block file in vendormoduleBlockOnePage
<?php
namespace vendormoduleBlockOnePage;
class CustomSuccess extends MagentoFrameworkViewElementTemplate
public function getCustomSuccess()
return 'Your custom block contents.';
- Create checkout_onepage_success.xml layout file in vendormoduleviewfrontendlayout
<?xml version="1.0"?>
<body>
<referenceContainer name="order.success.additional.info">
<block class="vendormoduleBlockOnePageCustomSuccess"
name="custom.order.success"
template="Vendor_Module::order/success.phtml"
after="-">
</block>
</referenceContainer>
</body>
- Lastly, create phtml template file in vendormoduleviewfrontendtemplatesorder
<?php /* @var $block vendormoduleBlockOnePageCustomSuccess */?>
<?php echo __('This is a custom content.'); ?>
<?php echo $block->getCustomSuccess(); ?>
Don't forget to run the upgrade command and redeploy static view files.
You can insert your own custom block
by overriding checkout_onepage_success.xml
Try the below steps:
- Create your CustomSuccess.php Block file in vendormoduleBlockOnePage
<?php
namespace vendormoduleBlockOnePage;
class CustomSuccess extends MagentoFrameworkViewElementTemplate
public function getCustomSuccess()
return 'Your custom block contents.';
- Create checkout_onepage_success.xml layout file in vendormoduleviewfrontendlayout
<?xml version="1.0"?>
<body>
<referenceContainer name="order.success.additional.info">
<block class="vendormoduleBlockOnePageCustomSuccess"
name="custom.order.success"
template="Vendor_Module::order/success.phtml"
after="-">
</block>
</referenceContainer>
</body>
- Lastly, create phtml template file in vendormoduleviewfrontendtemplatesorder
<?php /* @var $block vendormoduleBlockOnePageCustomSuccess */?>
<?php echo __('This is a custom content.'); ?>
<?php echo $block->getCustomSuccess(); ?>
Don't forget to run the upgrade command and redeploy static view files.
answered 2 days ago
magefmsmagefms
2,3872426
2,3872426
I have made layout xml changes as above butt still not working. I may have mixed it up with changes from both answers, I am not sure if below custom module di.xml, and module.xml are necessary since the custom template should get data from the new Block and display after OOB success page. Am I right? di.xml:<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorCheckoutBlockOnepageCustomSuccess"/>
module.xml:<module name="Vendor_Checkout" setup_version="2.0.0"> <sequence> <module name="Magento_Checkout"/> </sequence> </module>
– cnu
2 days ago
I removed above mentioned entries from di.xml and module.xml and I still don't see custom phtml code being rendered though the module is enabled, ran upgrade and deployed static assets, cleared cache as well couple of times. Not sure what I am missing now.
– cnu
2 days ago
At the end it was blank config entry in di.xml since layout entry already is referencing new Block and template phtml file as below. Other layout entry may have also worked but now left it with following and it's working now.<referenceContainer name="order.success.additional.info"> <block class="VendoNameCheckoutBlockOnepageCustomSuccess" name="custom.order.success" template="VendoName_Checkout::checkout/mysuccess.phtml" after="-"> </block> </referenceContainer>
– cnu
2 days ago
My bad, there was a lower case letter in the vendor name inside checkout_onepage_success.xml while referencing the custom template, hence it wasn't called. I saw this issue in Developer mode but didn't enable it again since I thought I had fixed. It came up again since I was trying multiple things
– cnu
2 days ago
add a comment |
I have made layout xml changes as above butt still not working. I may have mixed it up with changes from both answers, I am not sure if below custom module di.xml, and module.xml are necessary since the custom template should get data from the new Block and display after OOB success page. Am I right? di.xml:<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorCheckoutBlockOnepageCustomSuccess"/>
module.xml:<module name="Vendor_Checkout" setup_version="2.0.0"> <sequence> <module name="Magento_Checkout"/> </sequence> </module>
– cnu
2 days ago
I removed above mentioned entries from di.xml and module.xml and I still don't see custom phtml code being rendered though the module is enabled, ran upgrade and deployed static assets, cleared cache as well couple of times. Not sure what I am missing now.
– cnu
2 days ago
At the end it was blank config entry in di.xml since layout entry already is referencing new Block and template phtml file as below. Other layout entry may have also worked but now left it with following and it's working now.<referenceContainer name="order.success.additional.info"> <block class="VendoNameCheckoutBlockOnepageCustomSuccess" name="custom.order.success" template="VendoName_Checkout::checkout/mysuccess.phtml" after="-"> </block> </referenceContainer>
– cnu
2 days ago
My bad, there was a lower case letter in the vendor name inside checkout_onepage_success.xml while referencing the custom template, hence it wasn't called. I saw this issue in Developer mode but didn't enable it again since I thought I had fixed. It came up again since I was trying multiple things
– cnu
2 days ago
I have made layout xml changes as above butt still not working. I may have mixed it up with changes from both answers, I am not sure if below custom module di.xml, and module.xml are necessary since the custom template should get data from the new Block and display after OOB success page. Am I right? di.xml:
<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorCheckoutBlockOnepageCustomSuccess"/>
module.xml: <module name="Vendor_Checkout" setup_version="2.0.0"> <sequence> <module name="Magento_Checkout"/> </sequence> </module>
– cnu
2 days ago
I have made layout xml changes as above butt still not working. I may have mixed it up with changes from both answers, I am not sure if below custom module di.xml, and module.xml are necessary since the custom template should get data from the new Block and display after OOB success page. Am I right? di.xml:
<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorCheckoutBlockOnepageCustomSuccess"/>
module.xml: <module name="Vendor_Checkout" setup_version="2.0.0"> <sequence> <module name="Magento_Checkout"/> </sequence> </module>
– cnu
2 days ago
I removed above mentioned entries from di.xml and module.xml and I still don't see custom phtml code being rendered though the module is enabled, ran upgrade and deployed static assets, cleared cache as well couple of times. Not sure what I am missing now.
– cnu
2 days ago
I removed above mentioned entries from di.xml and module.xml and I still don't see custom phtml code being rendered though the module is enabled, ran upgrade and deployed static assets, cleared cache as well couple of times. Not sure what I am missing now.
– cnu
2 days ago
At the end it was blank config entry in di.xml since layout entry already is referencing new Block and template phtml file as below. Other layout entry may have also worked but now left it with following and it's working now.
<referenceContainer name="order.success.additional.info"> <block class="VendoNameCheckoutBlockOnepageCustomSuccess" name="custom.order.success" template="VendoName_Checkout::checkout/mysuccess.phtml" after="-"> </block> </referenceContainer>
– cnu
2 days ago
At the end it was blank config entry in di.xml since layout entry already is referencing new Block and template phtml file as below. Other layout entry may have also worked but now left it with following and it's working now.
<referenceContainer name="order.success.additional.info"> <block class="VendoNameCheckoutBlockOnepageCustomSuccess" name="custom.order.success" template="VendoName_Checkout::checkout/mysuccess.phtml" after="-"> </block> </referenceContainer>
– cnu
2 days ago
My bad, there was a lower case letter in the vendor name inside checkout_onepage_success.xml while referencing the custom template, hence it wasn't called. I saw this issue in Developer mode but didn't enable it again since I thought I had fixed. It came up again since I was trying multiple things
– cnu
2 days ago
My bad, there was a lower case letter in the vendor name inside checkout_onepage_success.xml while referencing the custom template, hence it wasn't called. I saw this issue in Developer mode but didn't enable it again since I thought I had fixed. It came up again since I was trying multiple things
– cnu
2 days ago
add a comment |
You can follow below file path to get additional order information to display order success page like order total.
File path: magento/app/code/Vendor/OrderSuccess/registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Vendor_OrderSuccess',
__DIR__
);
File path: magento/app/code/Vendor/OrderSuccess/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_OrderSuccess" setup_version="1.0.0">
<sequence>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
File path: magento/app/code/Vendor/OrderSuccess/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorOrderSuccessBlockOnepageCustomSuccess" />
</config>
File path:
magento/app/code/Vendor/OrderSuccess/Block/Onepage/CustomSuccess.php
<?php
namespace VendorOrderSuccessBlockOnepage;
class CustomSuccess extends MagentoCheckoutBlockOnepageSuccess
protected $orderItemsDetails;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderConfig $orderConfig,
MagentoFrameworkAppHttpContext $httpContext,
MagentoSalesModelOrder $orderItemsDetails,
array $data = []
)
parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data);
$this->orderItemsDetails = $orderItemsDetails;
public function getOrderItemsDetails()
$IncrementId = $this->_checkoutSession->getLastRealOrder()->getIncrementId();
$order = $this->orderItemsDetails->loadByIncrementId($IncrementId);
return $order;
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/layout/checkout_onepage_success.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="VendorOrderSuccessBlockOnepageCustomSuccess" name="checkout.successcustom" template="Vendor_OrderSuccess::mysuccess.phtml">
</block>
</referenceContainer>
</body>
</page>
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/templates/mysuccess.phtml
<?php $_order = $block->getOrderItemsDetails(); ?>
<?php echo "Sub Total"; ?><?php echo $_order->formatPrice($_order->getSubTotal()); ?>
<?php echo "Grand Total"; ?> <?php echo $_order->formatPrice($_order->getGrandTotal()); ?>
Let me know if any query.
Hope it help!
@cnu your commented xml code only work for default template.
– Kirti Nariya
2 days ago
Thanks Kirti. I see below entry in OOB checkout_onepage_success.xml, and I don't see anything printed or called from the customsuccess.phtml, is there anything else that needs to be done to use custom template code after OOB template data?
– cnu
2 days ago
<referenceContainer name="content"> <block class="MagentoCheckoutBlockOnepageSuccess" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"> <container name="order.success.additional.info" label="Order Success Additional Info"/> </block> <block class="MagentoCheckoutBlockRegistration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/> </referenceContainer>
– cnu
2 days ago
add a comment |
You can follow below file path to get additional order information to display order success page like order total.
File path: magento/app/code/Vendor/OrderSuccess/registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Vendor_OrderSuccess',
__DIR__
);
File path: magento/app/code/Vendor/OrderSuccess/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_OrderSuccess" setup_version="1.0.0">
<sequence>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
File path: magento/app/code/Vendor/OrderSuccess/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorOrderSuccessBlockOnepageCustomSuccess" />
</config>
File path:
magento/app/code/Vendor/OrderSuccess/Block/Onepage/CustomSuccess.php
<?php
namespace VendorOrderSuccessBlockOnepage;
class CustomSuccess extends MagentoCheckoutBlockOnepageSuccess
protected $orderItemsDetails;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderConfig $orderConfig,
MagentoFrameworkAppHttpContext $httpContext,
MagentoSalesModelOrder $orderItemsDetails,
array $data = []
)
parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data);
$this->orderItemsDetails = $orderItemsDetails;
public function getOrderItemsDetails()
$IncrementId = $this->_checkoutSession->getLastRealOrder()->getIncrementId();
$order = $this->orderItemsDetails->loadByIncrementId($IncrementId);
return $order;
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/layout/checkout_onepage_success.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="VendorOrderSuccessBlockOnepageCustomSuccess" name="checkout.successcustom" template="Vendor_OrderSuccess::mysuccess.phtml">
</block>
</referenceContainer>
</body>
</page>
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/templates/mysuccess.phtml
<?php $_order = $block->getOrderItemsDetails(); ?>
<?php echo "Sub Total"; ?><?php echo $_order->formatPrice($_order->getSubTotal()); ?>
<?php echo "Grand Total"; ?> <?php echo $_order->formatPrice($_order->getGrandTotal()); ?>
Let me know if any query.
Hope it help!
@cnu your commented xml code only work for default template.
– Kirti Nariya
2 days ago
Thanks Kirti. I see below entry in OOB checkout_onepage_success.xml, and I don't see anything printed or called from the customsuccess.phtml, is there anything else that needs to be done to use custom template code after OOB template data?
– cnu
2 days ago
<referenceContainer name="content"> <block class="MagentoCheckoutBlockOnepageSuccess" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"> <container name="order.success.additional.info" label="Order Success Additional Info"/> </block> <block class="MagentoCheckoutBlockRegistration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/> </referenceContainer>
– cnu
2 days ago
add a comment |
You can follow below file path to get additional order information to display order success page like order total.
File path: magento/app/code/Vendor/OrderSuccess/registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Vendor_OrderSuccess',
__DIR__
);
File path: magento/app/code/Vendor/OrderSuccess/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_OrderSuccess" setup_version="1.0.0">
<sequence>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
File path: magento/app/code/Vendor/OrderSuccess/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorOrderSuccessBlockOnepageCustomSuccess" />
</config>
File path:
magento/app/code/Vendor/OrderSuccess/Block/Onepage/CustomSuccess.php
<?php
namespace VendorOrderSuccessBlockOnepage;
class CustomSuccess extends MagentoCheckoutBlockOnepageSuccess
protected $orderItemsDetails;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderConfig $orderConfig,
MagentoFrameworkAppHttpContext $httpContext,
MagentoSalesModelOrder $orderItemsDetails,
array $data = []
)
parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data);
$this->orderItemsDetails = $orderItemsDetails;
public function getOrderItemsDetails()
$IncrementId = $this->_checkoutSession->getLastRealOrder()->getIncrementId();
$order = $this->orderItemsDetails->loadByIncrementId($IncrementId);
return $order;
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/layout/checkout_onepage_success.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="VendorOrderSuccessBlockOnepageCustomSuccess" name="checkout.successcustom" template="Vendor_OrderSuccess::mysuccess.phtml">
</block>
</referenceContainer>
</body>
</page>
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/templates/mysuccess.phtml
<?php $_order = $block->getOrderItemsDetails(); ?>
<?php echo "Sub Total"; ?><?php echo $_order->formatPrice($_order->getSubTotal()); ?>
<?php echo "Grand Total"; ?> <?php echo $_order->formatPrice($_order->getGrandTotal()); ?>
Let me know if any query.
Hope it help!
You can follow below file path to get additional order information to display order success page like order total.
File path: magento/app/code/Vendor/OrderSuccess/registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Vendor_OrderSuccess',
__DIR__
);
File path: magento/app/code/Vendor/OrderSuccess/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_OrderSuccess" setup_version="1.0.0">
<sequence>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
File path: magento/app/code/Vendor/OrderSuccess/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockOnepageSuccess" type="VendorOrderSuccessBlockOnepageCustomSuccess" />
</config>
File path:
magento/app/code/Vendor/OrderSuccess/Block/Onepage/CustomSuccess.php
<?php
namespace VendorOrderSuccessBlockOnepage;
class CustomSuccess extends MagentoCheckoutBlockOnepageSuccess
protected $orderItemsDetails;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCheckoutModelSession $checkoutSession,
MagentoSalesModelOrderConfig $orderConfig,
MagentoFrameworkAppHttpContext $httpContext,
MagentoSalesModelOrder $orderItemsDetails,
array $data = []
)
parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data);
$this->orderItemsDetails = $orderItemsDetails;
public function getOrderItemsDetails()
$IncrementId = $this->_checkoutSession->getLastRealOrder()->getIncrementId();
$order = $this->orderItemsDetails->loadByIncrementId($IncrementId);
return $order;
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/layout/checkout_onepage_success.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="VendorOrderSuccessBlockOnepageCustomSuccess" name="checkout.successcustom" template="Vendor_OrderSuccess::mysuccess.phtml">
</block>
</referenceContainer>
</body>
</page>
File path:
magento/app/code/Vendor/OrderSuccess/view/frontend/templates/mysuccess.phtml
<?php $_order = $block->getOrderItemsDetails(); ?>
<?php echo "Sub Total"; ?><?php echo $_order->formatPrice($_order->getSubTotal()); ?>
<?php echo "Grand Total"; ?> <?php echo $_order->formatPrice($_order->getGrandTotal()); ?>
Let me know if any query.
Hope it help!
answered 2 days ago
Kirti NariyaKirti Nariya
1,081415
1,081415
@cnu your commented xml code only work for default template.
– Kirti Nariya
2 days ago
Thanks Kirti. I see below entry in OOB checkout_onepage_success.xml, and I don't see anything printed or called from the customsuccess.phtml, is there anything else that needs to be done to use custom template code after OOB template data?
– cnu
2 days ago
<referenceContainer name="content"> <block class="MagentoCheckoutBlockOnepageSuccess" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"> <container name="order.success.additional.info" label="Order Success Additional Info"/> </block> <block class="MagentoCheckoutBlockRegistration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/> </referenceContainer>
– cnu
2 days ago
add a comment |
@cnu your commented xml code only work for default template.
– Kirti Nariya
2 days ago
Thanks Kirti. I see below entry in OOB checkout_onepage_success.xml, and I don't see anything printed or called from the customsuccess.phtml, is there anything else that needs to be done to use custom template code after OOB template data?
– cnu
2 days ago
<referenceContainer name="content"> <block class="MagentoCheckoutBlockOnepageSuccess" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"> <container name="order.success.additional.info" label="Order Success Additional Info"/> </block> <block class="MagentoCheckoutBlockRegistration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/> </referenceContainer>
– cnu
2 days ago
@cnu your commented xml code only work for default template.
– Kirti Nariya
2 days ago
@cnu your commented xml code only work for default template.
– Kirti Nariya
2 days ago
Thanks Kirti. I see below entry in OOB checkout_onepage_success.xml, and I don't see anything printed or called from the customsuccess.phtml, is there anything else that needs to be done to use custom template code after OOB template data?
– cnu
2 days ago
Thanks Kirti. I see below entry in OOB checkout_onepage_success.xml, and I don't see anything printed or called from the customsuccess.phtml, is there anything else that needs to be done to use custom template code after OOB template data?
– cnu
2 days ago
<referenceContainer name="content"> <block class="MagentoCheckoutBlockOnepageSuccess" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"> <container name="order.success.additional.info" label="Order Success Additional Info"/> </block> <block class="MagentoCheckoutBlockRegistration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/> </referenceContainer>
– cnu
2 days ago
<referenceContainer name="content"> <block class="MagentoCheckoutBlockOnepageSuccess" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"> <container name="order.success.additional.info" label="Order Success Additional Info"/> </block> <block class="MagentoCheckoutBlockRegistration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/> </referenceContainer>
– cnu
2 days ago
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268440%2fextend-magento-2-onepage-success-block-and-success-phtml-to-display-addition-ord%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
did you get any error?
– magefms
2 days ago
No errors, it wouldn't call any methods from the custom block and also doesn't display OOB order number and other information, all that section is blank on the success page with no errors.
– cnu
2 days ago