2

I want to add my custom template on checkout page in order summary just after Total as shown in screenshot :

enter image description here

In this template .phtml file I want to add some conversion depend on payment gateway just to display only to customer.

How can I do that?

Vinaya Maheshwari
  • 2,174
  • 3
  • 34
  • 76

1 Answers1

3

If we take a look the Json config of xml layout on checkout page:

enter image description here

As we can see, we can add the custom content to itemsBefore area.

For example code:

app/code/Vendor/Checkout/view/frontend/layout/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="testcustom" xsi:type="array">
                                                            <item name="component" xsi:type="string">Vendor_Checkout/js/view/summary/custom</item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

app/code/Vendor/Checkout/view/frontend/web/js/view/summary/custom.js

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

app/code/Vendor/Checkout/view/frontend/web/template/summary/custom.html

<div>Test Test Here</div>
Khoa TruongDinh
  • 32,054
  • 11
  • 88
  • 155