I am overriding the checkout success page, Vendor/Theme/Magento_Checkout/templates/success.phtml and I want to let the user to know that a confirmation e-mail is send to his/her e-mail address.

Is there any way to show the e-mail address, that the user has filled in the checkout page? I have tried searching for methods like getEmail but could not find anything.

1 Answer 1


Overwrite Magento\Checkout\Block\Onepage\Success


<?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="Magento\Checkout\Block\Onepage\Success" type="Vendor\Module\Block\Onepage\Success" />


namespace Vendor\Module\Block\Onepage;

class Success extends \Magento\Checkout\Block\Onepage\Success
    public function getEmail()
        $order = $this->_checkoutSession->getLastRealOrder();
        return $order->getCustomerEmail();

Now inside your success.phtml

<?php echo $block->getEmail(); ?>

Make sure your template is define inside checkout_onepage_success.xml following way:

<block class="Magento\Checkout\Block\Onepage\Success" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false"/>

That means Magento_Checkout before success.phtml in template attribute.

Clear cache.

  • If I were to reproduce this in app/ (instead of vendor/), would this be done in app/code or could I achieve this in my child theme under app/design/<theme>/<child_theme>?
    – Craig
    Jul 13, 2017 at 9:38
  • 'app/code/Vendor/Module' should be ok
    – Sohel Rana
    Jul 13, 2017 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.