Magento2 Checkout Page – Updating HTML Template Not Showing

checkoutmagento2template

I use Magento 2.0 for the first time and I am trying to make some changes on Checkout page. For example, I want to change template
module-checkout/view/frontend/web/template/estimation.html,
so I copied this template to my folder theme to
'Magento_Checkout/web/template/estimation.html'
and I made some changes in it, but nothing changes. Also, for a test, I changed original template but still, no changes.

I use grunt, I deployed the code, cleared all cache. On every other pages, changes do apply, but not on checkout. Do you have any guess, what am I doing wrong?

Also a question – is there any better explanation on how does checkout page on Magento2 work than the one from Magento page?

Best Answer

In your case, the Browser Cache caused your issue, we should disable it when developing and testing.

Chrome Browser

enter image description here

Firefox

enter image description here

is there any better explanation on how does checkout page on Magento 2 work than the one from Magento page?

I'm not sure my explanation is good enough to understand.

We need to take a look: vendor/magento/module-checkout/view/frontend/layout/checkout_index_index.xml. We will see a lot of config nodes. Magento layout for one page checkout comes from here.

Navigate to vendor/magento/module-checkout/view/frontend/templates/onepage.phtml:

 <script type="text/x-magento-init">
        {
            "#checkout": {
                "Magento_Ui/js/core/app": <?php /* @escapeNotVerified */ echo $block->getJsLayout();?>
            }
        }
    </script>
    <script>
        window.checkoutConfig = <?php /* @escapeNotVerified */ echo \Zend_Json::encode($block->getCheckoutConfig()); ?>;
        // Create aliases for customer.js model from customer module
        window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
        window.customerData = window.checkoutConfig.customerData;
    </script>

The most logic is here. $block->getJsLayout() gets the config from the xml layout. The js Magento_Ui/js/core/app is in charge of the rendering UI. There are some global javascript variables. These variables are used for other js components.

For the js and html templates file, Magento will load them from pub/static. They are copied to pub/static after running static content deploy.

Related Topic