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.

有帮助吗?

解决方案

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">
<body>
    <referenceContainer name="content">
        <block class="Magento\Framework\View\Element\Template" name="custom_text" template="Magento_Theme::block/custom_text.phtml" cacheable="false" />
    </referenceContainer>
</body>
</page>

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 ?>";
</script>

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

<span data-bind="html: dynamicText "></span>
许可以下: CC-BY-SA归因
scroll top