0

I am using the below code to show custom data.

file: 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>
        <referenceBlock name="checkout.cart.totals">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="block-totals" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="basetotal" xsi:type="array">
                                    <item name="component" xsi:type="string">Ishaq_CheckoutBaseTotal/js/view/checkout/cart/totals/basetotal</item>
                                    <item name="sortOrder" xsi:type="string">20</item>
                                    <item name="config" xsi:type="array">
                                        <item name="template" xsi:type="string">Ishaq_CheckoutBaseTotal/checkout/cart/totals/basetotal</item>
                                    </item>
                                </item>

                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

This is working properly but showing content after Subtotal.

I have used move tag as below but it has no effect.

<move element="checkout.cart.totals" destination="checkout.cart.methods" before="-" />

enter image description here

How to show contents before Proceed/Go to Checkout Button?

2 Answers 2

0

You can add your code in that template too

/app/design/frontend/Vendor/theme/Magento_Checkout/templates/onepage/link.phtml

or you can move via xml

<move element="your_element_name" destination="checkout.cart.methods" before="-" />
2
  • I am using move tag as suggested but still position of the content is same. see my updated question
    – ishaq
    Commented Nov 28, 2021 at 3:49
  • try to change name in your xml <referenceBlock name="checkout.cart.totals"> to <referenceBlock name="checkout.cart.methods"> Commented Nov 29, 2021 at 4:45
0

After Changing the XML file and using my KnocoutJS inside phtml now it is working.

app/code/Ishaq/CheckoutBaseTotal/view/frontend/layout/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="checkout.cart.totals.container">
            <block class="Magento\Framework\View\Element\Template" 
                name="checkout.cart.basetotal.block" 
                after="checkout.cart.totals" 
                template="Ishaq_CheckoutBaseTotal::basetotal.phtml" />
        </referenceContainer>
        
    </body>
</page>

app/code/Ishaq/CheckoutBaseTotal/view/frontend/templates/basetotal.phtml

<div id="basetotal-component" data-bind="scope:'basetotalcomponent'">
    <!-- ko template: getTemplate() --><!-- /ko -->
    <script type="text/x-magento-init">
    {
        "#basetotal-component": {
            "Magento_Ui/js/core/app": {
               "components": {
                    "basetotalcomponent": {
                        "component": "Ishaq_CheckoutBaseTotal/js/view/checkout/cart/totals/basetotal"
                    }
                }
            }
        }
    }
    </script>
</div>

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.