1

In Magento 2.3.5 How can I add a block of code/static content after Cart Total on checkout_cart_index.xml and checkout_index_index.xml?

I want this block should be observable so that if Cart Total changes it should also reload.

Want to add content below Order Total likewise on the payment review section also

enter image description here

Cart Total is changing according to product fees radio buttons (Mageworx Multi Fees extension)

4

1 Answer 1

2

try:-

create custom phtml exmaple:- custom.phtml

path:- app/code/Vendor/Module/view/frontend/templates/custom.phtml

add code in checkout_cart_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="cart.summary">
            <block class="Magento\Framework\View\Element\Template" name="custom" template="Vendor_Module::custom.phtml" before="checkout.cart.methods.bottom"/>
        </referenceContainer>
    </body>
</page>

create custom html

path:- app/code/Vendor/Module/view/frontend/web/template/custom.html

create custom js

path:- app/code/Vendor/Module/view/frontend/web/js/view/custom.js

define(
    [
        'uiComponent'
    ],
    function (Component) {
        'use strict';
        return Component.extend({
            defaults: {
                template: 'Vendor_Module/summary/custom'
            }
        });
    }
);

add code checkout_index_index.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="sidebar" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="summary" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="itemsBefore" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <item name="custom" xsi:type="array">
                                                            <item name="component" xsi:type="string">Vendor_Module/js/view/custom</item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
3
  • it is working on the cart page, how to show on the payment summary page.
    – ishaq
    Feb 1, 2021 at 10:22
  • please check the updated answer.
    – Himanshu
    Feb 1, 2021 at 11:03
  • how to show after subtotal?
    – Manjunath
    Oct 3, 2021 at 18:29

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.