2

I create a custom checkout block for checkout success page, but unfortunately the data printed twice, First in the right div inside body, and the other printed after the footer, here is the checkout_onepage_success.xml:

<?xml version="1.0"?>
<body>
    <referenceContainer name="order.success.additional.info">
        <block class="Namespace\Module\Block\Success"
               name="namespace.order.success"
               template="Namespace_Module::order/success.phtml"
               after="-">
        </block>
    </referenceContainer>
</body>
2
  • have you define block inside footer order.success.additional.info at any place? Feb 22 '17 at 5:06
  • @RakeshJesadiya nope
    – simple guy
    Feb 22 '17 at 5:13
0

You need to rewrite success block as below

create di.xml file at Namespace\Module\etc\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="Magento\Checkout\Block\Onepage\Success" type="Namespace\Module\Block\Success" />
</config>

Create your block file Success.php at Namespace\Module\Block\Success.php

Add below code to it.

<?php

namespace Namespace\Module\Block;

class Success extends \Magento\Checkout\Block\Onepage\Success
{
    /**
     * add your code here
     */

}
?>

Now add layout file checkout_onepage_success.xml at Namespace\Module\view\frontend\layout\checkout_onepage_success.xml

add below code to it

<?xml version="1.0"?>
<body>
    <referenceBlock name="checkout.success">
       <action method='setTemplate'>
          <argument name='template' xsi:type='string'>Namespace_Module::order/success.phtml</argument>
       </action>
    </referenceBlock>
</body>
0

The problem you are encountering is a bug in Magento 2: https://github.com/magento/magento2/issues/4999

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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