This is the default vendor/magento/module-checkout/view/frontend/layout/checkout_onepage_success.xml

This layout defines between other things :

<block class="Magento\Checkout\Block\Onepage\Success" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false">
    <container name="order.success.additional.info" label="Order Success Additional Info"/>

What I would like to do is add a piece of script like a simple:

    console.log('script added');

To the success.phtml template file.

What is the best way to do it ?

Notice that I already have a custom design/frontend/folder/Magento_Checkout/templates but success isn't in here. I guess I can add a custom success.phtml in this location, but I probably need to specify the new file somewhere ?

  • This should help you get started: magento.stackexchange.com/questions/301627/… As for success.phtml not being in templates, that is normal and requires you create the files you want to overwrite. I normally copy the existing file to my theme and then make changes as required. You won't need to reference it as long it is named the same and found in the same folder structure as the file you are overriding. Commented Jul 16, 2020 at 16:47

1 Answer 1


I recently added snippet of code to success page


Check the block logic, frontend layout and phtml

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.