I have added a custom text inside the cart summary checkout page using a simple HTML template file.

enter image description here

My question is how can I add dynamic content(from .phtml file or Block file) to this section? I want to process the grand total and add the order total in other/secondary currency.

1 Answer 1


You can get dynamic content in an HTML template by the below steps:
STEP 1: Create a new XML file in theme named checkout_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="content">
        <block class="Magento\Framework\View\Element\Template" name="custom_text" template="Magento_Theme::block/custom_text.phtml" cacheable="false" />

STEP 2 : create a PHTML file in the below location: app/design/frontend/{theme_package}/{theme_name}/Magento_Theme/templates/block/custom_text.phtml

<?php $dynamicText = 'Hello There'; // you can call any block or dynamic text here ?>
<script type="text/javascript">
    window.dynamicText = "<?php echo $dynamicText ?>";

STEP 3 : Add below code in .html file else any where in .html in checkout:

<span data-bind="html: dynamicText "></span>
  • This worked for me. There is some mistake you missed the closing page tag in layout file </page>
    – ishaq
    Jan 6, 2021 at 15:00
  • Thanks, @ishaq I have added this change in the code.
    – Amit Saini
    Jan 7, 2021 at 7:30
  • This works but not with Ajax. I have a custom dropdown on checkout page shipping address form, and on change event, the value is storing in table : quote_address. So on Change Event, i want to print the dropdown value with ajax below Order Summary title. Above solution works when i refresh the page. Let me know if any solution for ajax May 9, 2023 at 11:31

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.