3

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.

2

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

  • Thanks Khoa it helps me to get my answer posting it as answer so that it can help others please have a look on it if any changes requires – Ashish Madankar M2 Professiona Nov 16 '17 at 14:45
3

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.