Skip to content

Updating total savings block in cart

I’ve successfully added a total_savings block to my theme. It works well by doing the calculation in the phtml file.

themeMagento_Checkoutlayoutcheckout_cart_index.xml:

<?xml version="1.0"?>
<page layout="1column" 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="MagentoFrameworkViewElementTemplate" name="checkout.cart.total.savings" after="checkout.cart.totals" template="Magento_Checkout::total_savings.phtml" />
        </referenceContainer>
    </body>
</page>

But it doesn’t reload when editing the quantities of products, removing products, and so on. I need to refresh(F5) the whole page to reload that block.

How can I make my custom block reload? Would it reload if I could place the block inside the cart.totals block? Would prefer to do this in my theme…