Question

I want to change grand total i.e of on shopping cart page. I don't want to show any shipping or taxation on cart page all must be on checkout page only.

I tried with changing vendor\magento\module-checkout\view\frontend\web\js\model\totals.js like

if(i == 4){
    this.totals().total_segments[i].value = this.totals().total_segments[0].value;
    var total = this.totals().total_segments[i];
}

and it works for me but if I made any changes in it then it will reflect on chcekout page also I want it on shopping cart page only.

Can any one please suggest how can I achieve this.

Was it helpful?

Solution

Cart summary on Cart page also used the Ui component. So, we can replace the default with your custom js component. Take a look at the Tax xml layout, we can see some good examples here: vendor/magento/module-tax/view/frontend/layout/checkout_cart_index.xml

OTHER TIPS

Answer of Khoa helps me to get my solution but for just to explain in details I am posting my answer.

1) Create checkout_cart_index.xml file in your design with below content.

2) Clear cache and done.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" 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="grand-total" xsi:type="array">
                                    <item name="component"  xsi:type="string">Magento_Tax/js/view/checkout/summary/subtotal</item>
                                    <item name="config" xsi:type="array">
                                        <item name="template" xsi:type="string">Magento_Tax/checkout/summary/subtotal</item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top