cancel
Showing results for 
Search instead for 
Did you mean: 

Add in head own code

SOLVED

Add in head own code

Hello,

 

I added in admin some codes for the head section. This is working.

 

But I need at the success page, after checkout, another code in the head .. and only on this site.

 

How can I add this?

maybe edit the page:

vendor/magento/module-checkout/view/frontend/layout/checkout_onepage_success.xml?

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Add in head own code

Hello @hanhoe ,

Please add following code in your your theme's Magento_Checkout/layout/checkout_onepage_success.xml

<?xml version="1.0"?>
<body>
    <referenceContainer name="order.success.additional.info">
        <block 
               name="order.success.extra.info"
               template="order/info.phtml"
               after="-">
        </block>
    </referenceContainer>
</body>

And then in your theme's Magento_Checkout/templates/order/info.phtml add your own code.

If you don't want to add the code in your custom theme than you can do it by creating a custom module. For that please refer the link https://magento.stackexchange.com/questions/136730/call-custom-phtml-on-success-page-without-overrid...

I hope this will works for you, if still you face any issue please let me know.

If it helps you, please accept it as solution.

Regards.

View solution in original post

2 REPLIES 2

Re: Add in head own code

Hi @hanhoe,

Yes, you need to edit same file which you mentioned.

In the layout file you need to specify where you want to add your custom script using referenceContainer or referenceBlock.

For more details please follow below link:


https://magento.stackexchange.com/questions/285753/how-can-i-add-google-ads-tracking-code-in-success...

I will suggest to override xml file into your current theme.

I hope it will help you!

Re: Add in head own code

Hello @hanhoe ,

Please add following code in your your theme's Magento_Checkout/layout/checkout_onepage_success.xml

<?xml version="1.0"?>
<body>
    <referenceContainer name="order.success.additional.info">
        <block 
               name="order.success.extra.info"
               template="order/info.phtml"
               after="-">
        </block>
    </referenceContainer>
</body>

And then in your theme's Magento_Checkout/templates/order/info.phtml add your own code.

If you don't want to add the code in your custom theme than you can do it by creating a custom module. For that please refer the link https://magento.stackexchange.com/questions/136730/call-custom-phtml-on-success-page-without-overrid...

I hope this will works for you, if still you face any issue please let me know.

If it helps you, please accept it as solution.

Regards.